package com.cincc.cinccimdemo.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.cincc.im.core.IMSipPhoneCtrl;
import com.cincc.im.table.IMContactGroup;
import com.cincc.im.util.ImManager;

import java.util.List;

public class GroupListViewModel extends ViewModel {
    private MutableLiveData<List<IMContactGroup>> groupListLiveData;


    public MutableLiveData<List<IMContactGroup>> conversationListLiveData() {
        if (groupListLiveData == null) {
            groupListLiveData = new MutableLiveData<>();
        }
        ImManager.getInstance().getWorkHandler().post(() -> {
            List<IMContactGroup> contactGroups = IMSipPhoneCtrl.getInstance().getGroupList();
            groupListLiveData.postValue(contactGroups);
        });
        return groupListLiveData;
    }
}
